package fun.qu_an.minecraft.mini_games_helper.command;

import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
import fun.qu_an.minecraft.mini_games_helper.config.MiniGamesHelperConfig;
import fun.qu_an.minecraft.mini_games_helper.network.MGHConfigS2CPacket;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;

import static net.minecraft.server.command.CommandManager.literal;


public class MGHReloadCommand {
	public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
		dispatcher.register(literal("mghreload")
			.requires(source -> source.hasPermissionLevel(4))
			.executes(context -> {
				MiniGamesHelperConfig.load();
				context.getSource().getServer().getPlayerManager().getPlayerList().forEach(player
					-> MGHConfigS2CPacket.sendToClient(player, MiniGamesHelperConfig.get()));
				return 1;
			}));
	}
}
